import React, { Suspense } from 'react';
import { useRoutes } from 'react-router-dom'
const Home = React.lazy(() => import('../views/home'))
const Login = React.lazy(() => import('../views/login'))
const List = React.lazy(() => import('../views/list'))
const Layout = React.lazy(() => import('../layout/index'))


export const routes_list = [{
  path: '/login',
  element: <Login></Login>, 
}, {
  path: '/',
  element: <Layout></Layout>,
  children: [{
    path: '/',
    element: <Home></Home>
  },{
    path: '/list',
    element: <List></List>
  }]
}]

const Router = () => {
  const RouterView = () => useRoutes(routes_list)
  return (
    <Suspense fallback="路由加载中...">
      <RouterView></RouterView>
    </Suspense>
  )
}

export default Router